package com.zhiliao.template.demo1;

/**
 * 作者： zhi-liao
 * 类的作用:
 * 类的创建时间： 2021/5/23 15:16
 */
public class ConcreteSort extends AbstractSort {
    @Override
    protected void sort(int[] array) {
        for (int i = 0; i < array.length - 1; i++) {
            selectSort(array, i);
        }
    }

    private void selectSort(int[] array, int index) {
        int minValue = 32767;
        int indexMin = 0;
        int temp;
        for (int i = 0; i < array.length; i++) {
            if (array[i] < minValue) {
                minValue = array[i];
                indexMin = i;
            }
        }
        temp = array[index];
        array[index] = array[indexMin];
        array[indexMin] = temp;
    }
}
